<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
<script src="https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
	function getUrlParam(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
		var r = window.location.search.substr(1).match(reg); //匹配目标参数
		if (r != null)
			return unescape(r[2]);
		return null; //返回参数值
	}
	var wxOpenId = getUrlParam("wxOpenId");
	sessionStorage.setItem('wxOpenId', wxOpenId);
	function loginWxOpenId() {
		$.ajax({
			type : "get", //data 传送数据类型。post 传递
			dataType : 'json', // 返回数据的数据类型json
			url : "/controller/LoginWxOpenId", // yii 控制器/方法
			cache : false,
			data : {
				'wxOpenId' : wxOpenId,
				'applicationId' : '171220110147618'
			}, //传送的数据
			error : function() {
				alert("数据传输错误");
			},
			success : function(data) {
				if (data.code == 1) {
					sessionStorage.setItem('userSession', JSON.stringify(data.result));
					window.location.href = "dist/index.html#/home";
				}else{
					window.location.href = "dist/index.html#/login/" + wxOpenId;
				}
			}
		});
	}
	loginWxOpenId();
</script>
</html>
